/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.csvgenerator.engine.vg;

import java.lang.Math;

/**
 *
 * @author Administrator
 */
public class LinearValueGenerator extends  NumberValueGenerator {

    //elements
    private Long lowerBound = new Long(0);
    private Long upperBound = Long.MAX_VALUE;
    private Long step = new Long(1);
    private Long mod = new Long(1);
    private String prefix = "";
    private String suffix = "";
    
    //iterator variable holding previous value of ID
    private Long previousValue;
    
    private boolean overflow = false;
    
    public LinearValueGenerator(){}     
    
    @Override
    public String nextValue() {
        Long nextValue = previousValue + step;
        
        if (nextValue >= upperBound) {
            overflow = true;
            nextValue = lowerBound;          
        } 
        
        previousValue = nextValue;
        
        currentValue = prefix + nextValue + suffix;
        
        return currentValue;
    }

    public boolean isOverflow() {
        return overflow;
    }

    public void setOverflow(boolean overflow) {
        this.overflow = overflow;
    }

    /**
     * @return the lowerBound
     */
    public long getLowerBound() {
        return lowerBound;
    }

    /**
     * @param lowerBound the lowerBound to set
     */
    public void setLowerBound(long lowerBound) {        
        this.lowerBound = lowerBound;
        this.previousValue = lowerBound;
    }

    /**
     * @return the upperBound
     */
    public long getUpperBound() {
        return upperBound;
    }

    /**
     * @param upperBound the upperBound to set
     */
    public void setUpperBound(long upperBound) {
        this.upperBound = upperBound;
    }

    /**
     * @return the step
     */
    public long getStep() {
        return step;
    }

    /**
     * @param step the step to set
     */
    public void setStep(long step) {
        this.step = step;
    }

    /**
     * @return the mod
     */
    public long getMod() {
        return mod;
    }

    /**
     * @param mod the mod to set
     */
    public void setMod(long mod) {
        this.mod = mod;
    }

    /**
     * @return the prefix
     */
    public String getPrefix() {
        return prefix;
    }

    /**
     * @param prefix the prefix to set
     */
    public void setPrefix(String prefix) {
        this.prefix = prefix;
    }

    /**
     * @return the suffix
     */
    public String getSuffix() {
        return suffix;
    }

    /**
     * @param suffix the suffix to set
     */
    public void setSuffix(String suffix) {
        this.suffix = suffix;
    }

}
